
<%def name="createform(obj, table, act)">
<script type="text/javascript">
	$(function() {
			$("#datepicker").datepicker();
	});
</script>


% if not obj or not table or not act:
	Crap
	<% return  %>
% endif
<form action="${act}">
<table>
% for col in table.c:
	% if "visible" in col.info and not col.info["visible"]:
		% if getattr(obj, col.name):
			<input type="hidden" name="${col.name}" value="${getattr(obj, col.name)}" />
		% endif
		<% continue %>
	% endif
	
	<tr><td>
	% if "label" in col.info:
		<label for="${col.name}">${col.info["label"]} </label>
	% elif "label" not in col.info:
		<label for="${col.name}">${col.name} </label>
	% endif
	</td><td>
	% if "datatype" in col.info and col.info["datatype"] == "text":
		<textarea rows="3" cols="40" name="${col.name}">${getattr(obj, col.name)}</textarea>
	% elif "datatype" in col.info and col.info["datatype"] == "boolean":
		% if getattr(obj, col.name):
			<input type="radio" name="${col.name}" value="True" checked>True</input>
			<input type="radio" name="${col.name}" value="False">False </input>
		% else:
			<input type="radio" name="${col.name}" value="True">True</input>
			<input type="radio" name="${col.name}" value="False" checked>False</input>
		% endif		
	% elif "datatype" in col.info and col.info["datatype"] == "datetime":
		<input type="text" id="datepicker" name="${col.name}"
		% if getattr(obj, col.name):
			value="${getattr(obj, col.name).month}/${getattr(obj, col.name).day}/${getattr(obj, col.name).year}"
		% endif
		/>
	% elif "lookup" in col.info and hasattr(obj, col.info["lookup"]):
		<select name="${col.name}">
			% for o in getattr(obj, col.info["lookup"])():
				<option name = "${o}">${o}</option>
			% endfor
	% else:
		<input type=
		% if "type" in col.info:
			"${col.info["type"]}"
		% else:
			"text"
		% endif
		name="${col.name}"
		% if hasattr(col.type, "length"):
			maxlength=${col.type.length}
		% endif
		% if getattr(obj, col.name):
			value="${getattr(obj, col.name)}"
		% endif
		/>	
	% endif
	</td></tr>
% endfor
<tr><td></td><td><input type="submit" value="Save" /></td></tr>
</table>
</%def>
